package daobeauty.interceptor.invoke.factory.impl;

import java.lang.reflect.Method;

import daobeauty.interceptor.DaoMetaData;
import daobeauty.interceptor.invoke.InvokeStrategy;
import daobeauty.interceptor.invoke.factory.FilteringInvokeStrategyFactory;
import daobeauty.interceptor.invoke.impl.GetNamedQueryInvoke;
import daobeauty.interceptor.invoke.impl.NamedQueryDelegateInvoke;

public class NamedQueryDelegateInvokeFactory implements FilteringInvokeStrategyFactory{

	public boolean accept(DaoMetaData daoMetaData, Method daoMethod) {
		return GetNamedQueryInvoke.getNamedQuery(daoMethod.getName(), daoMetaData.getDomainClass(), daoMetaData.getSessionFactory().getCurrentSession())!=null;
	}

	public InvokeStrategy create(DaoMetaData daoMetaData, Method daoMethod) {
		return new NamedQueryDelegateInvoke(daoMethod, daoMetaData.getSessionFactory(), daoMetaData.getDomainClass());
	}

}
